package huawei.exam;

import java.util.HashMap;
import java.util.Scanner;

/**
 * @author : Rookie
 * @description :
 * @date : 2023/7/1
 */
public class IntegerArray {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String[] split1 = s.split(",");
        String s1 = scanner.nextLine();
        String[] split2 = s1.split(",");
        int[] arr1 = new int[split1.length];
        int[] arr2 = new int[split2.length];
        for (int i = 0; i < split1.length; i++) {
            arr1[i] = Integer.parseInt(split1[i]);
        }
        for (int i = 0; i < split2.length; i++) {
            arr2[i] = Integer.parseInt(split2[i]);
        }

        HashMap<Integer, Integer> hashMap = new HashMap<>();
        int i = 0,j = 0;
        while (i<arr1.length && j < arr2.length) {
            while (arr1[i] != arr2[j] && j < arr2.length - 1) {
                j++;
            }
            if (hashMap.containsKey(arr1[i])) {
                hashMap.put(arr1[i],hashMap.get(arr1[i]) + 1);
            } else {
                hashMap.put(arr1[i], 1);
            }
            j = 0;
            i++;
        }
        hashMap.forEach((key,value) -> {
            System.out.println(key + ":" + value);
        });
    }


}
